<template>
	<view class="container">
		<!-- 人脸识别 -->
		<!-- <view v-if="rlsb" style="width: 100%;height: 100%;position: absolute;left: 0;background-color: #fff;z-index: 99">
				  <view style="height: 250rpx;width: 250rpx;position: absolute;top:40%;left:50%;transform: translate(-50%, -50%);border-radius:50%;background: #000;"></view>
				  <view style="position: absolute;top:51%;left:50%;transform: translate(-50%, -50%);text-align: center;color: #000;">此处进行人脸识别</view>
		</view> -->
		<view class="hzimg">
			<image src="/static/hjzx.jpg"></image>
			<view class="hzText">
				{{ app.language.hjTopText }}
			</view>
		</view>
		<view class="listBox">
			<!-- 户籍办理提交记录 -->
			<view class="listText" @click="listText">
				<text>{{app.language.listText}}</text>
			</view>
			<!-- 户口注销 -->
			<view class="hjzxBox">
				<view class="hjTitle">
					<image src="/static/hjbl.png" class="hjTImg"></image>
					{{ app.language.hjTitle }}
				</view>
				<view class="listItem" v-for="(item, index) in hkzxList" v-if="hkzxList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
						<!-- <image src="/static/more.png"></image> -->
					</view>
				</view>
			</view>
			<!-- 出生登记 -->
			<view class="hjzxBox">
				<view class="hjTitle">
					<image src="/static/cs.png" class="hjTImg"></image>
					{{ app.language.csTitle }}
				</view>
				<view class="listItem" v-for="(item, index) in csdjList" v-if="csdjList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
						<!-- <image src="/static/more.png"></image> -->
					</view>
				</view>
			</view>
			<!-- 变更户政信息 -->
			<view class="hjzxBox">
				<view class="hjTitle">
					<image src="/static/hz.png" class="hjTImg"></image>
					{{ app.language.hzbgTitle }}
				</view>
				<view class="listItem" v-for="(item, index) in bghzList" v-if="bghzList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
						<!-- <image src="/static/more.png"></image> -->
					</view>
				</view>
			</view>
			<!-- 户口迁移 -->
			<view class="hjzxBox">
				<view class="hjTitle">
					<image src="/static/hk.png" class="hjTImg"></image>
					{{ app.language.hkqyTitle }}
				</view>
				<view class="listItem" v-for="(item, index) in hkqyList" v-if="hkqyList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
						<!-- <image src="/static/more.png"></image> -->
					</view>
				</view>
			</view>
			<!-- 居住证办理 -->
			<view class="hjzxBox">
				<view class="hjTitle">
					<image src="/static/jzz.png" class="hjTImg"></image>
					{{ app.language.jzzTitle }}
				</view>
				<view class="listItem" v-for="(item, index) in jzzList" v-if="hkqyList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
						<!-- <image src="/static/more.png"></image> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const global = getApp().globalData;
	export default {
		data() {
			return {
				rlsb: true,
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				// 户口注销
				hkzxList: [{
						id: "0",
						icon: "/static/hj.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "1",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
				],
				// 出生登记
				csdjList: [{
						id: "2",
						icon: "/static/hj.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "3",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: "7"
					},
					{
						id: "4",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
				],

				// 变更户政信息
				bghzList: [{
						id: "5",
						icon: "/static/hj.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "6",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "7",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
				],
				// 户口迁移
				hkqyList: [{
						id: "8",
						icon: "/static/hj.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "9",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
					{
						id: "10",
						icon: "/static/ld.png",
						path: "/pages/bmfw/form",
						name: ""
					},
				],
				// 居住证办理
				jzzList: [{
					id: "11",
					icon: "/static/hj.png",
					path: "/pages/bmfw/jzz",
					name: ""
				}],
				token: "",
				userInfo: {}
			}
		},
		onLoad() {
			this.hkzxList[0].name = this.app.language.text1
			this.hkzxList[1].name = this.app.language.text2
			this.csdjList[0].name = this.app.language.text3
			this.csdjList[1].name = this.app.language.text4
			this.csdjList[2].name = this.app.language.text5
			this.bghzList[0].name = this.app.language.text6
			this.bghzList[1].name = this.app.language.text7
			this.bghzList[2].name = this.app.language.text8
			this.hkqyList[0].name = this.app.language.text9
			this.hkqyList[1].name = this.app.language.text10
			this.hkqyList[2].name = this.app.language.text11
			this.jzzList[0].name = this.app.language.text12
			this.getToken()
		},

		methods: {
			// 获取缓存
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						// that.form.reportType = res.data.userInfo.peopleType
						that.token = res.data.userInfo.appToken
						that.userInfo = res.data.userInfo
						console.log('that.userInfo', that.userInfo)
					}
				});
			},
			handleHkzx(item) {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.navigateTo({
								url: item.path + '?id=' + item.id
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						// 身份作证号的
						if (!this.userInfo.agent) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.birthdate) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.idcard) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.nationality) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.policeNumber) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.personnelCategory) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.workTime) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.positionRank) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.marriage) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.height) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.weight) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						uni.navigateTo({
							url: item.path + '?id=' + item.id
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
			listText() {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/bmfw/listText'
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						// 身份作证号的
						if (!this.userInfo.agent) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.birthdate) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.idcard) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.nationality) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.policeNumber) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.personnelCategory) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.workTime) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.positionRank) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.marriage) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.height) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.weight) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						uni.reLaunch({
							url: '/pages/bmfw/listText'
						});

					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
		}
	}
</script>

<style>
	.listItem {
		margin: 10rpx 0;
		border-bottom: 1px dashed #ddd;
		padding-bottom: 14rpx;
	}

	.listBox {
		padding: 0 20rpx;
	}

	.list text {
		width: 89%;
		display: inline-block;
		font-size: 26rpx;
		padding-left: 5rpx;
	}

	.list image {
		width: 30rpx;
		height: 30rpx;
		position: relative;
		top: 5rpx;
		float: right;
	}

	.hzimg image {
		width: 100%;
		height: 222rpx;
	}

	.hzText {
		position: absolute;
		top: 70rpx;
		left: 137rpx;
		font-size: 44rpx;
		color: #2f8ef9;
	}

	.hjTitle {
		font-size: 30rpx;
		margin: 20rpx 0;
		font-weight: bold;
	}

	.hjzxBox {
		margin-bottom: 15rpx;
		box-shadow: 2rpx 2rpx 20rpx #ddd;
		padding: 0 10rpx 5rpx;
	}



	.listText {
		font-size: 28rpx;
		color: #2f8ef9;
		margin: 15rpx 0;
		text-align: right;
		font-weight: 500;
		/* border-bottom: 1px solid #ddd; */
		padding-bottom: 10rpx;
	}

	.listText text {
		border: 1px solid #2f8ef9;
		padding: 10rpx 15rpx;
		border-radius: 6rpx;
	}

	.hjTImg {
		width: 37rpx;
		height: 37rpx;
		margin-right: 8rpx;
		position: relative;
		top: 8rpx;
	}
</style>